package com.crscd.ai.controller;

import com.crscd.ai.assistant.XiaoZhiAgent;
import com.crscd.ai.entity.ChatForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2025/9/24-20:52
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@RestController
@RequestMapping("/xiaozhi")
public class XiaoZhiController {

  @Autowired private XiaoZhiAgent xiaozhiAgent;

  @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
  public Flux<String> chat(@RequestBody ChatForm chatForm) {
    return xiaozhiAgent.chat(chatForm.getMemoryId(), chatForm.getMessage());
  }
}
